package com.epam.rentcar.utils;

import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.epam.rentcar.transferobjects.User;

public class NotAuthorizedFilter extends GenericSecurityFilter {

	@Override
	protected boolean isValidRequest(ServletRequest request) {
		HttpServletRequest httpServletRequest = (HttpServletRequest) request;
		HttpSession session = httpServletRequest.getSession();
		User user = (User) session.getAttribute("user");
		return (user != null)?true:false;
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
	}

}
